var common = require('../pages/common/common.js');
var mulit = require('m.js');
const checkToken = (fn) => {
  const cookie = wx.getStorageSync('cookie')||'';
  const token = wx.getStorageSync('token')||'';
  const ttp = new Date().getTime();
  const sk = common.randomString(32);
  const myarray = ["timestamps", "signMark", 'signNark', 'cookie', 'token'];
  const nowArray = myarray.sort()
  const objectB = {
    timestamps: ttp,
    signMark: sk,
    signNark: 'tc',
    cookie: cookie,
    token: token
  }
  const str = mulit.hexMD5(encodeURIComponent(common.getString(myarray, objectB)));
  wx.request({
    header: { 'content-type': 'application/x-www-form-urlencoded' },
    url: common.common.CHECK_TOKEN,
    data: { 'timestamps': ttp, 'signMark': sk, 'sign': str, 'cookie': cookie, 'token': token },
    method: 'POST',
    success: fn

  })

}
module.exports.checkToken = checkToken